<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="com.wowangz.cms.common.utils.DataFormat"%>

<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp" %>

<%
	
	String timing = "";
	boolean timeOut = false;
	Date loginDate = null;
	Date logoutDate = null;
	if(userContext != null && userContext.getLoginDate() != null)
	{
		loginDate = userContext.getLoginDate();
		logoutDate = new Date(System.currentTimeMillis());
		int hours = logoutDate.getHours() - loginDate.getHours();
		int minutes = logoutDate.getMinutes() - loginDate.getMinutes();
		int seconds = logoutDate.getSeconds() - loginDate.getSeconds();
		if(hours > 0)
		{
			if(minutes < 0){
				hours = hours - 1;
				minutes = logoutDate.getMinutes();
			}
			if(seconds < 0){
				minutes = minutes - 1;
				seconds = logoutDate.getSeconds();
			}
		}
		else {
			if(seconds < 0){
				minutes = minutes - 1;
				seconds = logoutDate.getSeconds();
			}
		}
		timing = hours + "小时" + minutes + "分" + seconds + "秒";
	}
	else
	{
		timeOut = true;
		%>
		<script type="text/javascript">
		if(parent.window && parent.window != window) {
			parent.window.location.href='${systemctx}/login.jsp';
		}
		</script>
		<%
	}
%>

<form name="form1" id="form1" action="${systemctx}/login/userLogout.web" method="post">	
	<input type="hidden" name="errorPage" value="logout" />
	<div class="pageMain">
	<div class="pageTitle"><%=MessageResourcesUtils.getMessage(request,"common.logout.logout") %></div>
	<div class="pageBody">
		<div class="form-group">
			<p class="confirm-logout">
				<%=MessageResourcesUtils.getMessage(request,"common.logout.curtime") %><%=DataFormat.formatDate(logoutDate, DataFormat.DT_YYYYMMDD_HHMMSS)%>,&nbsp;&nbsp;&nbsp;&nbsp;<%=MessageResourcesUtils.getMessage(request,"common.logout.used") %><%=timing%>,&nbsp;&nbsp;&nbsp;&nbsp;<%=MessageResourcesUtils.getMessage(request,"common.logout.exit") %>
			</p>
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" name="butSubmit" id="butSubmit" value="<%=MessageResourcesUtils.getMessage(request,"common.button.comfirm") %>"/>
		</div>
	</div>
	</div>
</form>


<script type="text/javascript">
$(document).ready(function() {
	$('#butSubmit').click(function() {
		showSending();
		$.ajax({
			type : 'POST',
			url : '${systemctx}/login/userLogout.web',
			data : $("#form1").serialize(),
			dataType : 'json',
			success : function(data) {
				if(parent.window && parent.window != window) {
					parent.window.location.href='${systemctx}/login.jsp';
				}
			}
		});
	});
});
	
</script>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp" %>